package com.zoo.wuhua;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.Environment;

/**
 * 
 * <b></b><br>
 *
 * @author zhangli7@yusys.com.cn
 * @since 2019年10月24日 下午6:45:36
 */
@MapperScan("com.zoo.wuhua.mapper")
@SpringBootApplication
public class App {
    private static final Logger LOGGER = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) throws UnknownHostException {
        Environment env = SpringApplication.run(App.class, args).getEnvironment();
        String applicationName = env.getProperty("spring.application.name");
        String protocol = "http";
        if (env.getProperty("server.ssl.key-store") != null) {
            protocol = "https";
        }
        String contextPath = env.getProperty("server.servlet.context-path");
        String serverPort = env.getProperty("server.port");
        String localHostAddr = InetAddress.getLocalHost().getHostAddress();
        LOGGER.info("----------------------------------------------------------");
        LOGGER.info("\tApplication [{}] is running! Access URLs:", applicationName);
        LOGGER.info("\tLocal: \t\t{}://localhost:{}{}", protocol, serverPort, contextPath);
        LOGGER.info("\tExternal: \t{}://{}:{}{}", protocol, localHostAddr, serverPort, contextPath);
        LOGGER.info("\tProfile(s): \t{}", Arrays.toString(env.getActiveProfiles()));
        LOGGER.info("----------------------------------------------------------");
    }
}
